This patch fixes dom0 SMP vcpu hotplug. Currently, domains without
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 15 Nov 2005 16:30:55 +0000 (17:30 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 15 Nov 2005 16:30:55 +0000 (17:30 +0100)
config files (e.g. dom0) don't set info['vcpus'] correctly resulting in
incorrect cpu availablity values in the store.  This prevents hotplug
from functioning.

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
tools/python/xen/xend/XendDomainInfo.py

index c634cb862310bbbd1ad3b0c3568b44d3103bd899..3b50fc9be606e0ce0158406178d5b13d301e08fa 100644 (file)
@@ -437,12 +437,18 @@ class XendDomainInfo:
             defaultInfo('on_crash',     lambda: "restart")
             defaultInfo('cpu',          lambda: None)
             defaultInfo('cpu_weight',   lambda: 1.0)
-            defaultInfo('vcpus',        lambda: int(1))
-            defaultInfo('online_vcpus', lambda: self.info['vcpus'])
 
-            self.info['vcpus'] = int(self.info['vcpus'])
-            defaultInfo('max_vcpu_id',  lambda: self.info['vcpus']-1)
+            # some domains don't have a config file (e.g. dom0 )
+            # to set number of vcpus so we derive available cpus
+            # from max_vcpu_id which is present for running domains.
+            if not self.infoIsSet('vcpus') and self.infoIsSet('max_vcpu_id'):
+                avail = int(self.info['max_vcpu_id'])+1
+            else:
+                avail = int(1)
 
+            defaultInfo('vcpus',        lambda: avail)
+            defaultInfo('online_vcpus', lambda: self.info['vcpus'])
+            defaultInfo('max_vcpu_id',  lambda: self.info['vcpus']-1)
             defaultInfo('vcpu_avail',   lambda: (1 << self.info['vcpus']) - 1)
 
             defaultInfo('memory',       lambda: 0)